<!DOCTYPE html>

<html xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core">


<h:head>

	<style type="text/css">
	
		

ui-layout,.ui-layout-doc,.ui-layout-unit,.ui-layout-wrap,.ui-layout-bd,.ui-layout-hd
	{
	border: none;
}

.companyHeaderGrid tr,.companyHeaderGrid td {
	border: none;
}
</style>
</h:head>

<h:body>

	<ui:composition>


		<h:form id="packet_filter_form">


			<p:panelGrid columns="6" styleClass="companyHeaderGrid"
				style="min-width: 100%">
				<f:facet name="header">  Filtra Pacchetti  </f:facet>

				<h:outputLabel for="city" value="Citta: " />

				<p:autoComplete id="city" value="#{pacchettoBean.cittaSelezionata}"
					label="Citta Partenza" completeMethod="#{cittaBean.complete}"
					var="c" itemLabel="#{c.name}" minQueryLength="3" itemValue="#{c}"
					forceSelection="true" converter="cittaConverter">

					<p:ajax event="itemSelect" update="city" />

				</p:autoComplete>

				<h:outputLabel for="country" value="Stato: " />

				<p:autoComplete id="country" value="#{pacchettoBean.statoSel}"
					label="Stato" completeMethod="#{statiBean.complete}" var="c"
					itemLabel="#{c.name}" minQueryLength="2" itemValue="#{c}"
					forceSelection="true" converter="statiConv">

					<p:ajax event="itemSelect" update="country" />

				</p:autoComplete>

				<h:inputHidden id="txt6" value="#{pacchettoBean.prezzoMin}" />
				<h:inputHidden id="txt7" value="#{pacchettoBean.prezzoMax}" />

				<h:outputLabel for="cat_select" value="Categoria: " />
				<p:autoComplete id="cat_select"
					value="#{pacchettoBean.categoriaSelezionata}" label="Categoria"
					completeMethod="#{pacchettoBean.complete}" var="cat"
					itemLabel="#{cat.descrizione}" minQueryLength="1"
					itemValue="#{cat}" forceSelection="true" converter="convertCat"
					requiredMessage="Inserire la categoria">
					<p:ajax event="itemSelect" update="cat_select" />
				</p:autoComplete>


				<p:outputPanel width="100%" style="margin: 10px 10px 10px 10px">
					<h:outputText id="displayRange" value="Prezzo da a "
						style="padding: 5px" />
					<p:slider for="txt6,txt7" display="displayRange" style="width:100%"
						range="true" displayTemplate="Prezzo da {min} a {max}" step="100"
						maxValue="#{pacchettoBean.macPrezzoPack}" minValue="0" />
				</p:outputPanel>


				<h:outputLabel for="dataPartenza" value="Data Partenza" />
				<p:calendar id="dataPartenza" label="Data Partenza"
					pattern="dd/MM/yyyy" binding="#{dataPart}" showButtonPanel="true"
					pages="2" value="#{pacchettoBean.dataPartenza}">
					<p:ajax event="dateSelect" update="dataPartenza, dataRitorno" />

				</p:calendar>
				<h:inputHidden />

				<h:outputLabel for="dataRitorno" value="Data Ritorno" />
				<p:calendar id="dataRitorno" label="Data Ritorno"
					showButtonPanel="true" pages="2" pattern="dd/MM/yyyy"
					value="#{pacchettoBean.dataRitorno}">
					<p:ajax event="dateSelect" update="dataRitorno" />
				</p:calendar>




				<f:facet name="footer">
					<p:commandButton value="Filtra" icon="ui-icon-check"
						style="margin:0" actionListener="#{pacchettoBean.filtraPacchetti}"
						update=":packet_list_form" />
				</f:facet>

			</p:panelGrid>

		</h:form>


		<h:form id="packet_list_form">
			<!-- START - Tabella dei pacchetti -->

			<p:dataTable value="#{pacchettoBean.listaPacchettiFiltrati}"
				var="packet" id="cars" rowSelectMode="single" rows="10"
				selectionMode="single" sortMode="multiple"
				selection="#{pacchettoBean.pacchettoSelezionato}"
				rowKey="#{packet.citta}" scrollable="true" liveScroll="true"
				scrollHeight="300">

				<!-- Definisco cosa deve fare con la selezione -->
				<p:ajax event="rowSelect"
					oncomplete="window.location.href='packet_detail.xhtml'" />



				<f:facet name="header"> Pacchetti disponibili </f:facet>

				<p:column>
					<f:facet name="header"> Citta </f:facet> 
                     		#{packet.citta.name}
				</p:column>

				<p:column>
					<f:facet name="header"> Prezzo Totale</f:facet>
                    		 #{packet.prezzoScontato}
				</p:column>

				<p:column>
					<f:facet name="header"> Sconto </f:facet>
                     		#{packet.sconto}%
				</p:column>

				<p:column>
					<f:facet name="header"> Descrizione </f:facet>
                     		#{packet.descrizione_categoria}
				</p:column>

				<p:column>
					<f:facet name="header"> Data Partenza </f:facet>
                     		#{packet.dataPartenzaAsString}
				</p:column>

				<p:column>
					<f:facet name="header"> Data Ritorno </f:facet>
                     		#{packet.dataRitornoAsString}
				</p:column>

			</p:dataTable>

			<!-- END - Tabella dei pacchetti -->

		</h:form>



	</ui:composition>

</h:body>
</html>